<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="奖金部门ID" prop="jjDeptId">
      <el-input v-model="dataForm.jjDeptId" placeholder="奖金部门ID"></el-input>
    </el-form-item>
    <el-form-item label="奖金部门名称" prop="jjDeptName">
      <el-input v-model="dataForm.jjDeptName" placeholder="奖金部门名称"></el-input>
    </el-form-item>
    <el-form-item label="奖金分配ID" prop="fpId">
      <el-input v-model="dataForm.fpId" placeholder="奖金分配ID"></el-input>
    </el-form-item>
    <el-form-item label="奖金编号" prop="jjBh">
      <el-input v-model="dataForm.jjBh" placeholder="奖金编号"></el-input>
    </el-form-item>
    <el-form-item label="分组ID" prop="fzId">
      <el-input v-model="dataForm.fzId" placeholder="分组ID"></el-input>
    </el-form-item>
    <el-form-item label="分组名称" prop="fzName">
      <el-input v-model="dataForm.fzName" placeholder="分组名称"></el-input>
    </el-form-item>
    <el-form-item label="部门编号" prop="deptCode">
      <el-input v-model="dataForm.deptCode" placeholder="部门编号"></el-input>
    </el-form-item>
    <el-form-item label="部门名称" prop="deptName">
      <el-input v-model="dataForm.deptName" placeholder="部门名称"></el-input>
    </el-form-item>
    <el-form-item label="人员编号" prop="ryCode">
      <el-input v-model="dataForm.ryCode" placeholder="人员编号"></el-input>
    </el-form-item>
    <el-form-item label="人员名称" prop="ryName">
      <el-input v-model="dataForm.ryName" placeholder="人员名称"></el-input>
    </el-form-item>
    <el-form-item label="人员职务" prop="ryZhiwei">
      <el-input v-model="dataForm.ryZhiwei" placeholder="人员职务"></el-input>
    </el-form-item>
    <el-form-item label="人员职级" prop="ryZwjb">
      <el-input v-model="dataForm.ryZwjb" placeholder="人员职级"></el-input>
    </el-form-item>
    <el-form-item label="人员职级编号" prop="ryZwjbbh">
      <el-input v-model="dataForm.ryZwjbbh" placeholder="人员职级编号"></el-input>
    </el-form-item>
    <el-form-item label="考核分值" prop="config02">
      <el-input v-model="dataForm.config02" placeholder="考核分值"></el-input>
    </el-form-item>
    <el-form-item label="考核分级" prop="config03">
      <el-input v-model="dataForm.config03" placeholder="考核分级"></el-input>
    </el-form-item>
    <el-form-item label="奖金主项ID" prop="jjzxId">
      <el-input v-model="dataForm.jjzxId" placeholder="奖金主项ID"></el-input>
    </el-form-item>
    <el-form-item label="奖金主项名称" prop="jjzxMc">
      <el-input v-model="dataForm.jjzxMc" placeholder="奖金主项名称"></el-input>
    </el-form-item>
    <el-form-item label="奖金主项日期" prop="jjzxRq">
      <el-input v-model="dataForm.jjzxRq" placeholder="奖金主项日期"></el-input>
    </el-form-item>
    <el-form-item label="奖金项ID" prop="jjxId">
      <el-input v-model="dataForm.jjxId" placeholder="奖金项ID"></el-input>
    </el-form-item>
    <el-form-item label="奖金项名称" prop="jjxMc">
      <el-input v-model="dataForm.jjxMc" placeholder="奖金项名称"></el-input>
    </el-form-item>
    <el-form-item label="奖金金额" prop="jjJe">
      <el-input v-model="dataForm.jjJe" placeholder="奖金金额"></el-input>
    </el-form-item>
    <el-form-item label="定向奖金" prop="jjJeDx">
      <el-input v-model="dataForm.jjJeDx" placeholder="定向奖金"></el-input>
    </el-form-item>
    <el-form-item label="分配奖金" prop="jjJeFp">
      <el-input v-model="dataForm.jjJeFp" placeholder="分配奖金"></el-input>
    </el-form-item>
    <el-form-item label="加扣奖金" prop="jjJeJk">
      <el-input v-model="dataForm.jjJeJk" placeholder="加扣奖金"></el-input>
    </el-form-item>
    <el-form-item label="修改备注" prop="jjBz">
      <el-input v-model="dataForm.jjBz" placeholder="修改备注"></el-input>
    </el-form-item>
    <el-form-item label="原始金额" prop="jjYsje">
      <el-input v-model="dataForm.jjYsje" placeholder="原始金额"></el-input>
    </el-form-item>
    <el-form-item label="原始公式" prop="jjGssm">
      <el-input v-model="dataForm.jjGssm" placeholder="原始公式"></el-input>
    </el-form-item>
    <el-form-item label="原始计算" prop="jjGsjs">
      <el-input v-model="dataForm.jjGsjs" placeholder="原始计算"></el-input>
    </el-form-item>
    <el-form-item label="二级领导履历转换数据集合" prop="jjResumeList">
      <el-input v-model="dataForm.jjResumeList" placeholder="二级领导履历转换数据集合"></el-input>
    </el-form-item>
    <el-form-item label="建立时间" prop="createTime">
      <el-input v-model="dataForm.createTime" placeholder="建立时间"></el-input>
    </el-form-item>
    <el-form-item label="修改时间" prop="editTime">
      <el-input v-model="dataForm.editTime" placeholder="修改时间"></el-input>
    </el-form-item>
    <el-form-item label="建立部门ID" prop="createDeptId">
      <el-input v-model="dataForm.createDeptId" placeholder="建立部门ID"></el-input>
    </el-form-item>
    <el-form-item label="建立部门" prop="createDeptName">
      <el-input v-model="dataForm.createDeptName" placeholder="建立部门"></el-input>
    </el-form-item>
    <el-form-item label="建立人员ID" prop="createUserId">
      <el-input v-model="dataForm.createUserId" placeholder="建立人员ID"></el-input>
    </el-form-item>
    <el-form-item label="建立人员" prop="createUserName">
      <el-input v-model="dataForm.createUserName" placeholder="建立人员"></el-input>
    </el-form-item>
    <el-form-item label="修改部门ID" prop="editDeptId">
      <el-input v-model="dataForm.editDeptId" placeholder="修改部门ID"></el-input>
    </el-form-item>
    <el-form-item label="修改部门" prop="editDeptName">
      <el-input v-model="dataForm.editDeptName" placeholder="修改部门"></el-input>
    </el-form-item>
    <el-form-item label="修改人员ID" prop="editUserId">
      <el-input v-model="dataForm.editUserId" placeholder="修改人员ID"></el-input>
    </el-form-item>
    <el-form-item label="修改人员" prop="editUserName">
      <el-input v-model="dataForm.editUserName" placeholder="修改人员"></el-input>
    </el-form-item>
    <el-form-item label="数据状态（0删除、1正常）" prop="dataState">
      <el-input v-model="dataForm.dataState" placeholder="数据状态（0删除、1正常）"></el-input>
    </el-form-item>
    <el-form-item label="所属租户" prop="tenantId">
      <el-input v-model="dataForm.tenantId" placeholder="所属租户"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="dataFormSubmit()" v-if="canSubmit">确定</el-button>
      <el-button @click="visible = false">取消</el-button>
    </span>
  </el-dialog>
</template>

<script>
    import {getObj, addObj, putObj} from '@/api/jiangjin/jiangjinfpjjgrfppzmxb'

    export default {
    data () {
      return {
        visible: false,
        canSubmit: false,
        dataForm: {
          id: 0,
          jjDeptId: '',
          jjDeptName: '',
          fpId: '',
          jjBh: '',
          fzId: '',
          fzName: '',
          deptCode: '',
          deptName: '',
          ryCode: '',
          ryName: '',
          ryZhiwei: '',
          ryZwjb: '',
          ryZwjbbh: '',
          config02: '',
          config03: '',
          jjzxId: '',
          jjzxMc: '',
          jjzxRq: '',
          jjxId: '',
          jjxMc: '',
          jjJe: '',
          jjJeDx: '',
          jjJeFp: '',
          jjJeJk: '',
          jjBz: '',
          jjYsje: '',
          jjGssm: '',
          jjGsjs: '',
          jjResumeList: '',
          createTime: '',
          editTime: '',
          createDeptId: '',
          createDeptName: '',
          createUserId: '',
          createUserName: '',
          editDeptId: '',
          editDeptName: '',
          editUserId: '',
          editUserName: '',
          dataState: '',
          tenantId: ''
        },
        dataRule: {
          jjDeptId: [
            { required: true, message: '奖金部门ID不能为空', trigger: 'blur' }
          ],
          jjDeptName: [
            { required: true, message: '奖金部门名称不能为空', trigger: 'blur' }
          ],
          fpId: [
            { required: true, message: '奖金分配ID不能为空', trigger: 'blur' }
          ],
          jjBh: [
            { required: true, message: '奖金编号不能为空', trigger: 'blur' }
          ],
          fzId: [
            { required: true, message: '分组ID不能为空', trigger: 'blur' }
          ],
          fzName: [
            { required: true, message: '分组名称不能为空', trigger: 'blur' }
          ],
          deptCode: [
            { required: true, message: '部门编号不能为空', trigger: 'blur' }
          ],
          deptName: [
            { required: true, message: '部门名称不能为空', trigger: 'blur' }
          ],
          ryCode: [
            { required: true, message: '人员编号不能为空', trigger: 'blur' }
          ],
          ryName: [
            { required: true, message: '人员名称不能为空', trigger: 'blur' }
          ],
          ryZhiwei: [
            { required: true, message: '人员职务不能为空', trigger: 'blur' }
          ],
          ryZwjb: [
            { required: true, message: '人员职级不能为空', trigger: 'blur' }
          ],
          ryZwjbbh: [
            { required: true, message: '人员职级编号不能为空', trigger: 'blur' }
          ],
          config02: [
            { required: true, message: '考核分值不能为空', trigger: 'blur' }
          ],
          config03: [
            { required: true, message: '考核分级不能为空', trigger: 'blur' }
          ],
          jjzxId: [
            { required: true, message: '奖金主项ID不能为空', trigger: 'blur' }
          ],
          jjzxMc: [
            { required: true, message: '奖金主项名称不能为空', trigger: 'blur' }
          ],
          jjzxRq: [
            { required: true, message: '奖金主项日期不能为空', trigger: 'blur' }
          ],
          jjxId: [
            { required: true, message: '奖金项ID不能为空', trigger: 'blur' }
          ],
          jjxMc: [
            { required: true, message: '奖金项名称不能为空', trigger: 'blur' }
          ],
          jjJe: [
            { required: true, message: '奖金金额不能为空', trigger: 'blur' }
          ],
          jjJeDx: [
            { required: true, message: '定向奖金不能为空', trigger: 'blur' }
          ],
          jjJeFp: [
            { required: true, message: '分配奖金不能为空', trigger: 'blur' }
          ],
          jjJeJk: [
            { required: true, message: '加扣奖金不能为空', trigger: 'blur' }
          ],
          jjBz: [
            { required: true, message: '修改备注不能为空', trigger: 'blur' }
          ],
          jjYsje: [
            { required: true, message: '原始金额不能为空', trigger: 'blur' }
          ],
          jjGssm: [
            { required: true, message: '原始公式不能为空', trigger: 'blur' }
          ],
          jjGsjs: [
            { required: true, message: '原始计算不能为空', trigger: 'blur' }
          ],
          jjResumeList: [
            { required: true, message: '二级领导履历转换数据集合不能为空', trigger: 'blur' }
          ],
          createTime: [
            { required: true, message: '建立时间不能为空', trigger: 'blur' }
          ],
          editTime: [
            { required: true, message: '修改时间不能为空', trigger: 'blur' }
          ],
          createDeptId: [
            { required: true, message: '建立部门ID不能为空', trigger: 'blur' }
          ],
          createDeptName: [
            { required: true, message: '建立部门不能为空', trigger: 'blur' }
          ],
          createUserId: [
            { required: true, message: '建立人员ID不能为空', trigger: 'blur' }
          ],
          createUserName: [
            { required: true, message: '建立人员不能为空', trigger: 'blur' }
          ],
          editDeptId: [
            { required: true, message: '修改部门ID不能为空', trigger: 'blur' }
          ],
          editDeptName: [
            { required: true, message: '修改部门不能为空', trigger: 'blur' }
          ],
          editUserId: [
            { required: true, message: '修改人员ID不能为空', trigger: 'blur' }
          ],
          editUserName: [
            { required: true, message: '修改人员不能为空', trigger: 'blur' }
          ],
          dataState: [
            { required: true, message: '数据状态（0删除、1正常）不能为空', trigger: 'blur' }
          ],
          tenantId: [
            { required: true, message: '所属租户不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0;
        this.visible = true;
        this.canSubmit = true;
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            getObj(this.dataForm.id).then(response => {
                this.dataForm = response.data.data
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.canSubmit = false;
            if (this.dataForm.id) {
                putObj(this.dataForm).then(data => {
                    this.$notify.success('修改成功')
                    this.visible = false
                    this.$emit('refreshDataList')
                }).catch(() => {
                    this.canSubmit = true;
                });
            } else {
                addObj(this.dataForm).then(data => {
                    this.$notify.success('添加成功')
                    this.visible = false
                    this.$emit('refreshDataList')
                }).catch(() => {
                    this.canSubmit = true;
                });
            }
          }
        })
      }
    }
  }
</script>
